ShowTable of Contents
Overview
The IBM® Sametime® Connect client allows users to make telephone calls via IBM Sametime Unified Telephony (SUT). This functionality can be called from a browser, allowing its integration directly into the browser's default functionality. This article shows how to create such an extension and how to install it into Google Chrome.
This extension uses mechanisms similar to those described in the article Internet Explorer extension for Click-to-Call, adding a new entry to the context menu. After installing, when you highlight a phone number on a web page, you can right-click on the highlighted area and select the Call item. The number will then be called using Sametime Unified Telephony functions in your Sametime client.

Note that the text “Call” will change according to the locale of the browser, automatically selecting the appropriate language.
Installation and removal
To install the extension, download the attached zip file, expand it and drag and drop the file SUTPhone.crx file onto Chrome. If you encounter permissions problems, open the page chrome://extensions and drop the file onto that. This then causes the following dialog to be displayed:

If you click on Add, the extension is installed into the browser.
To remove the extension, open the Extensions page, locate the entry for this extension, and click on the trash icon on the right. This will remove the functionality immediately.

How does it work?
This section assumes that you are familiar with the concept of creating an extension to Google Chrome. If you are not, there is a link at the end of the article which references information on how to do so.
In this case, the extension is to the context menu, so this is flagged in the manifest.json file, along with the fact that the JavaScript that manages the extension is in the file SUTPhone.js, highlighted in bold in Listing 1.
Listing 1: The extension manifest
{
"name": "Sametime Unified Telephony extension for Google Chrome",
"version": "0.1",
"manifest_version": 2,
"icons": { "16" : "phone16.png",
"48" : "phone48.png",
"128": "phone128.png" },
"description": "Calls a phone number highlighted on a web page",
"default_locale": "en",
"permissions": ["contextMenus"],
"background": { "scripts": ["SUTPhone.js"] }
}
In the JavaScript, we create the reference to the new context menu extension, and tell it that it should execute the makePhoneCall fuction, as shown in Listing 2.
Listing 2: Enabling the extension
chrome.contextMenus.create({
"title": chrome.i18n.getMessage("contextMenuCall"),
"contexts":["selection"],
"onclick": makePhoneCall});
The text displayed in the context menu, referred to here as the title field, is localized, and the individual translations are in the __locales subdirectory. In fact, there is only one word translated, but it illustrates the principal of how to approach localization in a Chrome extension. This JavaScript also indicates that the function should run on a selection on the page, executing makePhoneCall when the menu item is clicked.
Since the function is called on the currently selected text in the page, Chrome conveniently passes the appropriate information, i.e. the selected part of the page. In fact the info parameter also contains other information, includin the URL of the page. Another parameter, tab, provides information about the current tab. This allows us to easily extract the phone number to be called.
Finally, the string is passed to SUT. We use a trick here to allow JavaScript to run without causing any cross-domain issues. The URL of the REST API in the Sametime Connect client is used as the src= parameter of an HTML image, causing that address to be called, resulting in the SUT API being executed and the call is placed as required.
Listing 3: Making the call
function makePhoneCall(info, tab) {
var SUTNum = info.selectionText.trim();
// Have we a number to call?
if (0 < SUTNum.length) {
// Create an image object: used to avoid cross-domain issues
image = new Image();
image.src = "http://localhost:59449/stwebapi/call?number=" + SUTNum;
// Prevent memory leak - destroy the image
image = null;
}
}
Requirements
There are a number of requirements for the extension to function as required:
-
You must have the Sametime Connect client running and be logged in to Sametime.
-
You must have SUT installed and configured correctly.
-
You must enable access to the Connect Web API in the Sametime client.
The Sametime Connect Web API may be disabled by default. To see the current state of each function, login to Sametime and go to http://localhost:59449/stwebapi/listservices in your browser. Functions that are disabled can be enabled by adding a preference to the file plugin_customization.ini in {Notes Install Directory}\framework\rcp if using the embedded client, or {Sametime Install Directory}\rcp if you have the Sametime Connect client, using the following format:
com.ibm.collaboration.realtime.webapi.Enabled=true
For example, to enable the call function you would add this preference:
com.ibm.collaboration.realtime.webapi.callEnabled=true
To enable all Web API functions you can use the global override:
com.ibm.collaboration.realtime.webapi/enableAllWebApisOverride=true
Conclusion
When browsing the web, you can now make a phone call to a number which is on any web page with very little effort, enhacing your browsing experience by improved integration of Sametime into Google Chrome.
The sample code discussed here is attached to the article. Expand the "Attachments" section below to download the zip file.
Resources
• developerWorks® IBM Sametime product page: http://www.ibm.com/developerworks/lotus/products/instantmessaging/
• Community article “Firefox Plugin for Click to Call”: http://www-10.lotus.com/ldd/stwiki.nsf/dx/Firefox_Plugin_for_Click_to_Call
• Wiki article “Internet Explorer extension for Click-to-Call”: http://www-10.lotus.com/ldd/stwiki.nsf/dx/Internet_Explorer_extension_for_Click-to-Call
• Google documentation “Getting Started: Building a Chrome Extension”: http://developer.chrome.com/extensions/getstarted.html
About the author
Brendan Murray joined Lotus Development in 1991 and was acquired, along with the rest of the company, by IBM in 1995. Most recently he has been working on Sametime with a particular emphasis on its Web functionality. You can reach him at brendan_murray@ie.ibm.com.